class Task16:
    def __init__(self):
        self.invalid = False

    def run(self, base, exponent):
        if self.rough_equal(base, 0) and exponent == 0:
            self.invalid = True
            return 1
        else:
            self.invalid = False

        is_negative_exponent = exponent < 0
        if is_negative_exponent:
            exponent = -exponent
        result = self.power_with_unsigned_exponent(base, exponent)
        if is_negative_exponent:
            result = 1 / result
        return result

    def power_with_unsigned_exponent(self, base, exponent):
        if exponent == 0:
            return 1
        elif exponent & 1 == 0:
            temp = self.power_with_unsigned_exponent(base, exponent >> 1)
            return temp * temp
        else:
            temp = self.power_with_unsigned_exponent(base, exponent >> 1)
            return temp * temp * base

    def rough_equal(self, num1, num2, eps=1e-5):
        return (num1 - eps) < num2 < (num1 + eps)
